//////////////////////////////////////////////////////////////////////////

#ifndef _SAVER_H_
#define _SAVER_H_

//////////////////////////////////////////////////////////////////////////

#ifndef _BUFFER_H_
#include "buffer.h"
#endif

#ifndef _PACKET_H_
#include "packet.h"
#endif

//////////////////////////////////////////////////////////////////////////

class Player;
class Bullet;
class ServerState;
class ServerStatePacket;
class ServerInfo;
class ServerInfoPacket;
class ServerEventPacket;
class ServerStartPacket;
class GameObject;
class ClientInput;
class ClientInputPacket;
class ClientInfo;
class ClientInfoPacket;
class ClientIDPacket;
class TimePacket;
class ServerStatisticsPacket;

//////////////////////////////////////////////////////////////////////////


/** This class saves objects to buffer
*
*
*  @author   Roman Pasechnik
*  @author   Anastasia Karpinska
*  @since    Nov 15th, 2009
*  @updated  May 20th, 2010
*/
class Saver
{
//////////////////////////////////////////////////////////////////////////

public:

//////////////////////////////////////////////////////////////////////////


    /** Gets buffer with saved objects */
    const Buffer& GetBuffer() const;


    /** Saves server state packet */
    void SaveServerStatePacket( const ServerStatePacket& _serverStatePacket );


    /** Saves server info packet */
    void SaveServerInfoPacket( const ServerInfoPacket& _serverInfoPacket );


    /** Saves server event packet */
    void SaveServerEventPacket( const ServerEventPacket& _serverEventPacket );


    /** Saves server start packet */
    void SaveServerStartPacket( const ServerStartPacket& _serverStartPacket );


    /** Saves server statistics packet */
    void SaveServerStatisticsPacket( const ServerStatisticsPacket& _serverStatPacket );


    /** Saves client input packet */
    void SaveClientInputPacket( const ClientInputPacket& _clientInputPacket );


    /** Saves client info packet */
    void SaveClientInfoPacket( const ClientInfoPacket& _clientInfoPacket );


    /** Saves client ID packet */
    void SaveClientIDPacket( const ClientIDPacket& _clientIDPacket );



//////////////////////////////////////////////////////////////////////////

private:

//////////////////////////////////////////////////////////////////////////


    /** Saves player */
    void SavePlayer( const Player& _player );


    /** Saves bullet */
    void SaveBullet( const Bullet& _bullet );


    /** Saves game object */
    void SaveObject( const GameObject& _gameObject );


    /** Gets size of buffer which is necessary for storing an object*/
    int SavedObjectSize();


//////////////////////////////////////////////////////////////////////////


    /** Saves client input */
    void SaveClientInput( const ClientInput& _clientInput );


    /** Saves client info */
    void SaveClientInfo( const ClientInfo& _clientInfo );


    /** Saves time packet */
    void SaveTimePacket( const TimePacket& _timePacket );


    /** Saves packet code */
    void SavePacketCode( Packet::PacketCode _code );


    /** Saves server state */
    void SaveServerState( const ServerState& _state );


    /** Saves server info */
    void SaveServerInfo( const ServerInfo& _serverInfo );


//////////////////////////////////////////////////////////////////////////


    /** Saver buffer */
    Buffer m_Buffer;


//////////////////////////////////////////////////////////////////////////
};


//////////////////////////////////////////////////////////////////////////

#endif

//////////////////////////////////////////////////////////////////////////

